home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 29 Mar 1996 06:08:52 -0600
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4jgjsk$sbp@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com> <4j6389$3iq@solutions.solon.com> <4ja3s4$par@solutions.solon.com> <4je1pp$g2r@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4je1pp$g2r@solutions.solon.com>,
- J. Kanze <kanze@gabi-soft.fr> wrote:
- >In article <4jckoq$a32@solutions.solon.com> Lawrence Kirby
- ><fred@genesis.demon.co.uk> writes:
- >
- >|> In article <4ja3s4$par@solutions.solon.com>
- >|> kanze@lts.sel.alcatel.de "James Kanze US/ESC 60/3/141 #40763" writes:
- >
- >|> >I agree about not using any old arbitrary order, but the cv-qualifiers
- >|> >should definitly come *after* what they modify. It is only in the
- >|> >declaration-specifier that you have any freedom. In the declarator,
- >|> >the cv-qualifier *must* follow what it modifies. So why do it any
- >|> >differently here.
- >
- >|> Personally I think it reads more clearly with the qualifier prior to the
- >|> type.
- >
- >Except when it is a pointer that is const, n'est-ce pas? :-)
-
- When it's a pointer, we are talking about different syntactic units. The
- pointer clause is part of the declarator, not the specifier list.
- You have no choice, because the grammar is something like:
-
- indirect-declarator:
- pointer_opt direct-declarator
- ... other productions
-
- pointer:
- * qualifier_opt pointer_opt
- ... other productions
-
- So to make the optional type qualifier bind with the pointer, you _must_ put it
- after the *, otherwise it is part of the specifier list to the left.
-
- >I'll admit that it somehow `looks' more natural to put the const first,
- >at least, until you get used to the other alternative. (This may be
- >related to the fact that we put adjectives in front of the noun in
- >English, and that we somehow feal that const is an adjective.) I find
-
- Le integer const!
-
- We can't have someone living on French soil agree with an Englishman about
- where to place a qualifier.
-
- >it more consistent to put the const after, however, since I have to do
- >so anyway in some cases.
-
- Up to you!
- --
-